//
//  WPSetPayPwdViewController.m
//  ZhongChouPingTai
//
//  Created by WeiPan on 16/4/1.
//  Copyright © 2016年 WPJoe. All rights reserved.
//

#import "WPSetPayPwdViewController.h"

static NSString *const kUITableViewCellIdentifier = @"cellIdentifier";

@interface WPSetPayPwdViewController ()<UITableViewDataSource, UITableViewDelegate>
@property (nonatomic, strong) UITableView * setPayPwdTableView;
@property (nonatomic, strong) NSArray * payPwdArr;
- (void)initializeDataSource; /**< 初始化数据源 */
- (void)initializeUserInterface; /**< 初始化用户界面 */


@end

@implementation WPSetPayPwdViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    [self initializeDataSource];
    [self initializeUserInterface];
}
#pragma mark - init
- (void)initializeDataSource {
    self.payPwdArr = @[@[@"xgmm.png", @"修改支付密码", @"WPChangePayPwdViewController"],
  @[@"szmm.png", @"找回支付密码", @"WPFindPayPwdViewController"]];
}
- (void)initializeUserInterface {
    [self.view addSubview:self.setPayPwdTableView];
}
#pragma mark - 协议UITableViewDataSource
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return _payPwdArr.count;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:kUITableViewCellIdentifier];
    if (!cell) {
        cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:kUITableViewCellIdentifier];
    }
    cell.accessoryType = UITableViewCellAccessoryNone;
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
    cell.imageView.image = IMAGE_NAME(_payPwdArr[indexPath.row][0]);
    cell.textLabel.text = _payPwdArr[indexPath.row][1];
    cell.textLabel.font = [UIFont systemFontOfSize:14*DHFlexibleHorizontalMutiplier()];
    return cell;
}
#pragma mark - UITableViewDelegate
//用户点击了某一行
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    [self pushToNextController:[[NSClassFromString(_payPwdArr[indexPath.row][2]) alloc]init] withVCTitle:nil];
}
#pragma mark - getter
- (UITableView *)setPayPwdTableView {
    if (!_setPayPwdTableView) {
        _setPayPwdTableView = ({
            UITableView * tableview = [[UITableView alloc]initWithFrame:CGRectMake(0, navBar_Fheight+10, SCREEN_SIZE.width, SCREEN_SIZE.height - navBar_Fheight-10) style:UITableViewStylePlain];
            tableview.dataSource = self;
            tableview.delegate = self;
            tableview.tableFooterView = [UIView new];
            tableview.pagingEnabled = NO;
            tableview.bounces = NO;
            tableview.scrollEnabled = NO;
            tableview.separatorColor = COLOR_RGB(211, 211, 211, 1);
            tableview.backgroundColor = [UIColor clearColor];
            tableview;
        });
    }
    return _setPayPwdTableView;
}
@end
